const { Article } = require('../../model/article');
const pagination = require('mongoose-sex-page');

module.exports = async (req, res) => {
    const page = req.query.page;
     req.app.locals.currentLink = 'index';

    // 从数据库中查询数据
    let result = await pagination(Article).page(page).size(4).display(5).populate('author').exec();
    
    let str = JSON.stringify(result);
    let json = JSON.parse(str);
    
    // 渲染模板
    res.render('home/default', {
        result:json
    });
 
}